package com.game.dao.user.pet;

import com.coment.po.UserPet;
import com.xs.action.exection.ActionException;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface UserPetDao extends MongoRepository<UserPet, String> {

    default UserPet findByIdMust(String integer) {
        Optional<UserPet> optional = findById(integer);
        return optional.orElseThrow(() -> new ActionException("玩家未拥有该宠物"));
    }

    Optional<UserPet> findUserPetByUserInfoIdAndPetId(int userInfoId, int petId);

    List<UserPet> searchAllByUserInfoId(int userInfoId);
}
